package com.csw.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo06FlatMap {
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setAppName("flatMap")
      .setMaster("local")

    val sc: SparkContext = new SparkContext(conf)

    val rdd1: RDD[String] = sc.parallelize(List("csw,csw1,csw2","csw3,csw4,csw5"))

    /**
      * flatMap: 将一行数据拆分成多行数据
      *
      */
    val rdd2: RDD[String] = rdd1.flatMap(i=>i.split(","))

    rdd2.foreach(println)
  }
}
